package com.chis.jmdatatimer.main;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author jw
 * @Description:jmcityService启动类
 * @Company:zwx
 * @date:2016年5月26日
 */
public class HbaseMain {
	/**
	 * JmLlService入口
	 *
	 * @param args args
	 * @throws Exception 系统异常
	 */
	public static void main(String[] args) throws Exception {
//		HBaseConfiguration configuration = new HBaseConfiguration();
//		HTable hTable = new HTable(configuration,"jmll:td_predata");
//
//		Put put = new Put(Bytes.toBytes("YXZJ"));
//		put.addColumn(Bytes.toBytes("DATA"),Bytes.toBytes("NAME"),Bytes.toBytes("hzh"));
//		put.addColumn(Bytes.toBytes("DATA"),Bytes.toBytes("AGE"),Bytes.toBytes(12));
//
//		hTable.put(put);
//		hTable.close();

		HBaseConfiguration configuration = new HBaseConfiguration();
		HTable hTable = new HTable(configuration,"jmll:td_predata");
		Scan scan = new Scan();
		ResultScanner scanner = hTable.getScanner(scan);
		List<String> res = new ArrayList<>();
		for (Result result : scanner) {
			res.add(new String(result.getRow(),"UTF-8"));
		}
		System.out.println(res.size() + " : "+ res.toString());
		hTable.close();

	}
}
